/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.Participant;
import bpmn.WebService;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Web Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.WebServiceImpl#getParticipantRef <em>Participant Ref</em>}</li>
 *   <li>{@link bpmn.impl.WebServiceImpl#getInterface <em>Interface</em>}</li>
 *   <li>{@link bpmn.impl.WebServiceImpl#getOperation <em>Operation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WebServiceImpl extends BPMNElementImpl implements WebService {
	/**
	 * The cached value of the '{@link #getParticipantRef() <em>Participant Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParticipantRef()
	 * @generated
	 * @ordered
	 */
	protected Participant participantRef;

	/**
	 * The default value of the '{@link #getInterface() <em>Interface</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterface()
	 * @generated
	 * @ordered
	 */
	protected static final String INTERFACE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getInterface() <em>Interface</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterface()
	 * @generated
	 * @ordered
	 */
	protected String interface_ = INTERFACE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOperation() <em>Operation</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperation()
	 * @generated
	 * @ordered
	 */
	protected EList<String> operation;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WebServiceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.WEB_SERVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Participant getParticipantRef() {
		if (participantRef != null && participantRef.eIsProxy()) {
			InternalEObject oldParticipantRef = (InternalEObject)participantRef;
			participantRef = (Participant)eResolveProxy(oldParticipantRef);
			if (participantRef != oldParticipantRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.WEB_SERVICE__PARTICIPANT_REF, oldParticipantRef, participantRef));
			}
		}
		return participantRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Participant basicGetParticipantRef() {
		return participantRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParticipantRef(Participant newParticipantRef) {
		Participant oldParticipantRef = participantRef;
		participantRef = newParticipantRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.WEB_SERVICE__PARTICIPANT_REF, oldParticipantRef, participantRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getInterface() {
		return interface_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInterface(String newInterface) {
		String oldInterface = interface_;
		interface_ = newInterface;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.WEB_SERVICE__INTERFACE, oldInterface, interface_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getOperation() {
		if (operation == null) {
			operation = new EDataTypeUniqueEList<String>(String.class, this, BpmnPackage.WEB_SERVICE__OPERATION);
		}
		return operation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.WEB_SERVICE__PARTICIPANT_REF:
				if (resolve) return getParticipantRef();
				return basicGetParticipantRef();
			case BpmnPackage.WEB_SERVICE__INTERFACE:
				return getInterface();
			case BpmnPackage.WEB_SERVICE__OPERATION:
				return getOperation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.WEB_SERVICE__PARTICIPANT_REF:
				setParticipantRef((Participant)newValue);
				return;
			case BpmnPackage.WEB_SERVICE__INTERFACE:
				setInterface((String)newValue);
				return;
			case BpmnPackage.WEB_SERVICE__OPERATION:
				getOperation().clear();
				getOperation().addAll((Collection<? extends String>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.WEB_SERVICE__PARTICIPANT_REF:
				setParticipantRef((Participant)null);
				return;
			case BpmnPackage.WEB_SERVICE__INTERFACE:
				setInterface(INTERFACE_EDEFAULT);
				return;
			case BpmnPackage.WEB_SERVICE__OPERATION:
				getOperation().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.WEB_SERVICE__PARTICIPANT_REF:
				return participantRef != null;
			case BpmnPackage.WEB_SERVICE__INTERFACE:
				return INTERFACE_EDEFAULT == null ? interface_ != null : !INTERFACE_EDEFAULT.equals(interface_);
			case BpmnPackage.WEB_SERVICE__OPERATION:
				return operation != null && !operation.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (Interface: ");
		result.append(interface_);
		result.append(", Operation: ");
		result.append(operation);
		result.append(')');
		return result.toString();
	}

} //WebServiceImpl
